﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brouteforce.Animation;

namespace Brouteforce.NewManagers {
    public class TransitionManager : Manager {

        public static TransitionManager Instance = new TransitionManager();

        HashSet<Transition> transitions = new HashSet<Transition>();

        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime, BFGame game) {
        }

        protected override void _Update(Microsoft.Xna.Framework.GameTime gameTime, BFGame game) {
            List<Transition> toRemove = new List<Transition>();
            foreach (var t in transitions) {
                if (1.0 - t.Value < 0.00000001) {
                    toRemove.Add(t);
                    t.ReportFinish();
                } else t.interpolate(gameTime);
            }
            toRemove.ForEach(t => transitions.Remove(t));
        }

        public override void LoadContent(Microsoft.Xna.Framework.Content.ContentManager content) {
        }

        public override void Initialize() {
        }

        public void AddTransition(Transition t) {
            transitions.Add(t);
        }
    }
}
